using System;
using Framework;
using UnityEngine;

public class MainView : View
{
    private void Awake()
    {
        transform.GetButton("ShowM2Btn").onClick.AddListener(OnShowM2);
        transform.GetButton("TestEventBtn").onClick.AddListener(OnTestEventBtn);
        transform.GetButton("AddModuleViewBtn").onClick.AddListener(OnAddModuleView);
        
        // gameObject.GetComponent<dds>()

        // AddChildView<LList>()
    }

    private void OnShowM2()
    {
        ModuleManager.ShowModule(ModuleName.M2);

        
    }

    protected override void Init()
    {
        
    }

    protected override void RegisterEvent()
    {
        
    }

    private void TestEvent1Handle()
    {
        Log.Debug("收到事件MainEvent.TestEvent1");
    }

    private void OnTestEventBtn()
    {
        // Log.Error("Delay Call Start>>>>" + Time.realtimeSinceStartup);
        // DelayCall(1, () =>
        // {
        //     Log.Error("Delay Call>>>>" + Time.realtimeSinceStartup);
        // });


        CountDown(1, remaing =>
        {
            Log.Error(DateTime.Now.ToString());
            
        }, () =>
        {
            Log.Error("Delay Call Start>>>>" + Time.realtimeSinceStartup);
        }, Timer.GetCurrentTime() + 10 * 1000);
        
        TriggerEvent(MainEvent.TestEvent1);
    }

    private void OnEnable()
    {
        Log.Debug("View OnEnable");
    }

    private void Start()
    {
        Log.Debug("View Start");
    }

    private void OnAddModuleView()
    {
        Log.Error("OnAddModuleView");

        AddModuleView("View/GreenView.prefab", typeof(GreenView));
    }


}
